package com.tata.test.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.tata.test.UserService;
import com.tata.test.bean.UserBean;
import com.tata.util.BaseAction;

@Namespace(value = "/")
@ParentPackage(value = "struts-default")
@Action(value = "userAction", results = { 
	@Result(name = "success", location = "/success.jsp") 
})
public class UserAction extends BaseAction {

	@Autowired
	private UserService userService = null;

	@Override
	public String execute() throws Exception {
		System.out.println("测试一下");
		return SUCCESS;
	}

	public String getUserList() throws Exception {
		for (UserBean userBean : userService.getUserList()) {
			System.out.println(userBean.getUsername() + ","
					+ userBean.getPassword() + "," + userBean.getTruename());
		}
		return SUCCESS;
	}
}
